﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace ScreenUp
{
    public class ScreenUpSnapshotter
    {
        //gr.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
        //gr.CopyFromScreen(this.Left, this.Top, 0, 0, this.Size, CopyPixelOperation.SourceCopy);
        public Bitmap GetSnapshot(int X, int Y, Size size)
        {
            Bitmap bmp = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb);

            // Creating graphic object from the image
            Graphics gr = Graphics.FromImage(bmp);

            // Taking the snapshot
            gr.CopyFromScreen(X, Y, 0, 0, size, CopyPixelOperation.SourceCopy);
            return bmp;
        }
    }
}
